package sust.cse.ruhul.jpbs1.util;

import android.annotation.TargetApi;
import android.hardware.Camera;
import android.os.Build;

public class CameraUtil
{
	private static int cameras = -1;

	@TargetApi(Build.VERSION_CODES.GINGERBREAD)
	public static boolean hasCamera()
	{
		if (cameras == -1)
		{
			if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO)
			{
				try
				{
					android.hardware.Camera.open();
					cameras = 1;
				}
				catch (final Exception e)
				{
					// ignore this exception, just checking...
					cameras = 0;
				}
			}
			else
			{
				cameras = Camera.getNumberOfCameras();
			}
		}
		return cameras > 0;
	}

}
